<!--  -->
<template>
    <div>

        <van-form @submit="onSubmit" @failed="failedMethod">

            <!-- 头部 -->
            <div class="font15 mt10">
                <div class="pl10">
                    <span class="titletext ">{{ params.isDrawup == '1' ? '项目开工起草' : nFromdata.title }}</span>
                </div>

                <div v-if="params.isDrawup != '1'" class="graytext mt10 mb5 font13 pl10">
                    <span>工单编号：</span>
                    <span class="titletext">{{ nFromdata.pmInsId }}</span>
                </div>

                <div v-if="params.isDrawup == '1'" class="redtext mt10 mb5 font13 pl10">
                    <span>提示：该表单带*字段都为必填项</span>
                </div>

                <div class="bcolor-e" style="height: 2px;"></div>
            </div>

            <section-header :sectionTitle="'项目信息'"></section-header>
            <div>
                <van-field readonly required name="projectName" :value="mFromdata.projectName" label="项目名称:"
                    label-width="5em" />
                <van-field readonly required name="projectID" :value="mFromdata.projectID" label="项目编码:"
                    label-width="5em" />
                <van-field readonly required name="customerName" :value="mFromdata.customerName" label="集团名称:"
                    label-width="5em" />
                <van-field readonly required name="customerCode" :value="mFromdata.customerCode" label="集团编号:"
                    label-width="5em" />
                <van-field readonly required name="city" :value="mFromdata.city" label="地市:" label-width="3em" />
                <van-field readonly required name="counties" :value="mFromdata.counties" label="县区:"
                    label-width="3em" />
            </div>

            <section-header :sectionTitle="'里程碑信息'"></section-header>
            <div>
                <van-field readonly required name="milestoneNode" :value="mFromdata.milestoneNode" label="里程碑节点:"
                    label-width="6em" />
                <van-field readonly required name="planEndDate" :value="mFromdata.planEndDate" label="计划完成时间:"
                    label-width="7em" />
                <van-field readonly required autosize type="textarea" rows="1" name="milestoneDescribe"
                    :value="mFromdata.milestoneDescribe" label="里程碑描述:" label-width="6em" />
            </div>

            <section-header :sectionTitle="'发起开工'"></section-header>
            <div>
                <van-field readonly required name="actualDeliverer" :value="mFromdata.actualDeliverer" label="发起人姓名:"
                    label-width="6em" />
                <van-field readonly required name="actualDelivererAcount" :value="mFromdata.actualDelivererAcount"
                    label="发起人OA账号:" label-width="7.5em" />
                <van-field readonly required name="postponeStatus" :value="mFromdata.postponeStatus" label="逾期状态:"
                    label-width="5em" />
                <van-field v-if="mFromdata.postponeStatus == '逾期'" readonly required name="postponeDuration"
                           v-model="mFromdata.postponeDuration" label="延期时长:" label-width="5em" />
                <van-field v-if="mFromdata.postponeStatus == '逾期'" :readonly="!formEditable" required autosize
                         type="textarea" rows="1" name="postponeCause" v-model="mFromdata.postponeCause" label="逾期原因:"
                         label-width="5em" :rules="[{ required: formEditable, message: '请填写逾期原因' }]" />
                <van-field readonly name="constructUnit" :value="mFromdata.constructUnit" label="承建单位:"
                           label-width="5em" />
                <van-field readonly name="constructionUnit" :value="mFromdata.constructionUnit" label="施工单位:"
                         label-width="5em" />
                <van-field readonly name="meetingTime" :value="mFromdata.meetingTime" label="会议时间:"
                           label-width="5em" />
                <van-field readonly name="supervisionUnit" :value="mFromdata.supervisionUnit" label="监理单位:"
                         label-width="5em" />

                <van-field readonly required :right-icon="formEditable ? 'arrow' : ''" name="actualDeliveryTime"
                           :value="mFromdata.actualDeliveryTime" label="实际开工时间:" label-width="7em"
                           @click="showActualDeliveryTimePopupView = formEditable"
                           :rules="[{ required: formEditable, message: '请填写实际开工时间' }]" />
                <van-popup v-model="showActualDeliveryTimePopupView" position="bottom" get-container="body">
                  <van-datetime-picker v-model="currentDate" :formatter="formatter" type="date"
                                       @confirm="actualDeliveryTimeOnComfirm" @cancel="showActualDeliveryTimePopupView = false" />
                </van-popup>
                <div>
                    <van-field label-width="10em" readonly label="开工报告扫描件:" class="lyy-width" input-align="left"
                        required placeholder="">
                        <template #button v-if="formEditable">
                            <van-uploader :after-read="didFinishPickingFiles">
                                <van-button size="small" icon="plus" type="primary">AI+</van-button>
                            </van-uploader>
                        </template>
                    </van-field>

                    <div v-for="(fileitem, index) in mFromdata.reportFile" :key="fileitem.id" style="margin-left:20px">
                        <div readonly class="font14 fileLink" style="color:#0F85CF">
                            <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName
                                }}</a>
                        </div>
                        <van-icon v-if="formEditable" name="close" color="#ea0023" size="20"
                            @click="deleteFile(index)"></van-icon>
                    </div>
                </div>

                <van-field :readonly="!formEditable" autosize type="textarea" rows="1" name="remark"
                    v-model="mFromdata.remark" label="备注:" label-width="3em" />
            </div>
            <div v-if="aiDataResult&&aiDataResult.resultData&&!sysFiles&&sysFiles.length<1">
              <ai-el-table :aiDataResult="aiDataResult"></ai-el-table>
            </div>
            <div v-else-if="formEditable&&sysFiles&&sysFiles.length>0">
              <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
                <div class="blue_item" />
                <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">AI解析结果</span>
              </div>
              <el-table  :data="sysFiles" border style="width: 100%">
                <el-table-column prop="fileName" width="100px" label="文档名称" />
                <el-table-column prop="creator" label="上传人" />
                <el-table-column prop="createdTime" label="上传时间" />
                <el-table-column prop="state" label="AI解析状态" />
              </el-table>
              <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
                <div class="blue_item" />
                <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">AI解析详情</span>
              </div>
              <el-table  :data="analysisData" border style="width: 100%">
                <el-table-column type="index" width="40px" label="序号" />
                <el-table-column prop="fieldName" label="关键字段名称" />
                <el-table-column prop="dictValue" label="DICT系统数据" />
                <el-table-column label="AI解析结果" >
                  <template v-slot:default="scope">
                    <div v-if="Array.isArray(scope.row.aiOldValue) && scope.row.aiOldValue.length>0&&isBase64(scope.row.aiOldValue[0])" >
                      <div v-for="(item,index) in scope.row.aiOldValue" :key="index">
                        <img :src="'data:image/jpg;base64,'+item" style='width:50px;margin-left:5px;cursor:pointer;'>
                      </div>
                    </div>
                    <div v-else class="w100 f-1">
                      <div>{{scope.row.aiOldValue}}</div>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column prop="equalResult" label="一致性对比结果" >
                  <template v-slot:default="scope">
                    <div class="w100 f-1">
                      <div v-if="scope.row.equalResult=='不一致'" style="color: red">{{scope.row.equalResult}}</div>
                      <div v-else-if="scope.row.equalResult=='一致'" style="color: green">{{scope.row.equalResult}}</div>
                      <div v-else>{{scope.row.equalResult}}</div>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column prop="editValue" label="人工修正AI解析结果" width="200" align="center">
                  <template slot-scope="scope">
                    <van-field v-model="scope.row.editValue" rows="1" autosize label="" type="textarea" placeholder="请输入修正内容" @blur="editValueChange(scope.$index,scope.row.editValue)"
                    />
                  </template>
                </el-table-column>
              </el-table>
            </div>

            <!-- 跳转意见 -->
            <div v-if="showOpinionMoudle" class="left_botton">
                <button block type="button" @click="tomsg()" style="color:#60a9ec; display: inline-block;width:100%;border: 0px solid #60a9ec;border-radius: 15px 0px 0px 15px;
            padding:10px 10px 10px 15px;font-size:13px">意见</button>
            </div>

            <!-- 流转下一步 -->
            <div v-if="showNextButton" class="footer">
                <van-button block type="info" native-type="submit"
                    style="display: inline-block; width: 100%; border: 0px solid #60a9ec">{{ buttonTitle }}</van-button>
            </div>
        </van-form>


        <!-- 当前办理人 -->
        <section-header v-if="showHistoryMoudle" :sectionTitle="'当前办理人'"></section-header>
        <div v-if="showHistoryMoudle" class="font13 ptandpb10 pl16">
            <div>
                <span class="titletext font13">{{
                    historydata.MANAGER
                    }}</span>
            </div>
            <div class="mt5">
                <span class="graytext font12">{{ historydata.DEPARTMENT }}</span>
            </div>
        </div>


        <!-- 审批意见 -->
        <section-header v-if="showOpinionMoudle" id="opinion" :sectionTitle="'审批意见'"></section-header>
        <div v-if="showOpinionMoudle">
            <div v-if="approveList.length > 0" class="swrap" style="width: 100%">
                <div class="spiece_flex" v-for="(item, index) in approveList" :key="index">
                    <div class="vertical-a-t display-ib" style="width: 25px">
                        <i v-if="index == 0" class="iconfont icon-current font16 color-red2"></i>
                        <i v-if="index > 0" class="iconfont icon-yiban font16 color-theme"></i>
                        <div v-if="index != approveList.length - 1" class="optionline"></div>
                    </div>

                    <div class="vertical-a-t display-ib" style="width: calc(100%)">
                        <div style="white-space: nowrap">
                            <span class="color-theme font14">{{ item.producerName || "暂无" }}：</span>
                            <span class="color-2 font14">{{ item.content || "暂无" }}</span>
                        </div>

                        <div class="mt05 color-8" style="display: flex; align-items: baseline">
                            <div class="display-ib vertical-a-t font12" style="margin-top: 2px; width: 100%">
                                {{ item.companyName + ' - ' + item.departmentName || "暂无" }}
                            </div>

                            <div class="display-ib vertical-a-t font12 text-r" style="
                  margin-left: 10px;
                  margin-top: 2px;
                  text-align: right;
                  width: 100%;
                ">
                                {{ item.modifiedTime || "暂无" }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div v-else>
                <div class="color-9 font12 text-c">暂无数据</div>
            </div>
        </div>

        <!-- 底部占位 -->
        <div style="padding-bottom: 42px"></div>
    </div>
</template>


<script>

import { mapGetters } from "vuex";
import {Dialog, Notify, Toast} from "vant";
import moment from 'moment'

import { openFileUrl } from "@/store/openFile";
import util from "@/assets/js/public";

import {
  getSZTDZJFormDetail,
  findProjectStartModelByProjectStartId,
  getWfOptMags,
  getWfLinkTracks,
  projectMilestoneFindAll,
  findOnSaleTeamManageByProjectId,
  verifyStartProjectMilestoneNodes,
  uploadFileCommon, fileParsingRequestAnalysisFlowQuery, fileParsingCurrencyHttp, saveFileParsingRequestLog
} from "@/api/dictapi";
import SectionHeader from '../sztdzj/sztdzjDetail/section-header.vue';
import aiElTable from "@/components/aiElTable/index.vue";
import aiUtils from "@/assets/js/aiUtils";


export default {
    data() {
        return {
            params: {},
            todotype: false,
            toRead: false,
            approveList: [],
            historydata: {},
            nFromdata: {},
            mFromdata: {},
            showActualDeliveryTimePopupView: false,
            currentDate: new Date(),
            buttonTitle: '流转下一步',
            aiDataResult:{},
            sysFiles:[],
            analysisData:[],
            idKey:''
        };
    },

    computed: {
        ...mapGetters(["user"]),
        ...mapGetters(["userinfo"]),
        formEditable() {
            return this.params.location === 'dict.start' || this.params.isDrawup == '1';
        },
        /// 意见
        showOpinionMoudle() {
            return this.params.isDrawup != '1';
        },
        showHistoryMoudle() {
            return this.params.todoType == "2" && this.historydata.MANAGER && this.params.isDrawup != '1';
        },
        showNextButton() {
            return this.todotype || this.toRead || this.params.isDrawup == '1';
        }
    },

    //生命周期--挂载完成
    components: {
        aiElTable,
        SectionHeader
    },
    //生命周期--创建完成
    created() {
    },

    //生命周期--挂载完成
    mounted() {
        /// 办理 - 从待办进来（界面每次都会重新创建，所以不需要考虑缓存的问题）
        if (this.$route.query.isDrawup != '1') {
            this.params = this.$route.query;
            if (this.params.pmInsType == null && this.params.processType != null) {
                this.params.pmInsType = this.params.processType
            }
            if (this.params.todoType == "1") {
                this.todotype = true;
            }
            else if (this.params.todoType == "3") {
                this.toRead = true;
            }
            this.getdetail();
        }
    },
    activated() {
    },

    beforeRouteEnter(to, from, next) {
        next(vm => {
            // console.log('AA', to, 'AAAA', from);
            // 起草 - 从二级商机列表进来（界面因为保活问题，第二次从商机列表进来的时候 created方法不会重新调用，所以需要确保商机列表进来（或唤醒）时，要刷新起草数据）
            // 通过 `vm` 访问组件实例
            if (to.query.isDrawup == '1' && from.name === 'drawup_transition_tab') {
                vm.params = to.query;
                vm.requestDrawupInfo(to.query.projectId);
            }
        });
    },

    //方法调用
    methods: {
        editValueChange(index,value){
          if (this.analysisData[JSON.stringify(index)].dictValue==value){
            this.analysisData[JSON.stringify(index)].equalResult='一致'
          }
          this.analysisData=JSON.parse(JSON.stringify(this.analysisData))
        },
        failedMethod(data) {

            console.log('submit fail:', data);
            const errorArr = data.errors;
            const errorObj = errorArr[0];
            const errorMessage = errorObj.message;
            Toast({ type: 'text', message: errorMessage, duration: 1000 });
        },

        tomsg() {
            document.getElementById('opinion').scrollIntoView({ behavior: 'smooth' })
        },

        openFileUrlfun(value) {
            this.$router.push({
                name: "fileview",
                query: {
                    openFileUrl: openFileUrl(value),
                },
            });
        },



        /// 项目流转 的请求
        getdetail() {
            Toast.loading({ message: "加载中", forbidClick: false });
            getSZTDZJFormDetail(
                Object.assign(this.params, { userName: this.user.userName })
            ).then((result) => {
                Toast.clear();
                if (!result.data) {
                    Notify(result.message);
                    return;
                }
                if (result.data.data) {
                    this.nFromdata = result.data.data;
                }
                this.getDecisionMakingByPmInsId(result.data.data.projectInformationId);
            })
            getWfOptMags(Object.assign(this.params), {
                userName: this.user.userName,
            }).then((result) => {
                Toast.clear();
                if (!result.data) {
                    Notify(result.message);
                    return;
                }
                this.approveList = result.data.data.reverse();
            })
            if (this.params.todoType == "2") {
                getWfLinkTracks(Object.assign(this.params), {
                    userName: this.user.userName,
                }).then((result) => {
                    Toast.clear();
                    if (!result.data) {
                        Notify(result.message);
                        return;
                    }
                    if (result.data.data) {
                        //数据过滤，并生成新的数组
                        this.historydata = result.data.data.filter(
                            (item) => item.CURRENTSTATE == 10
                        )[0];
                    }
                })
            }
        },
        getDecisionMakingByPmInsId(value) {
            findProjectStartModelByProjectStartId(
                Object.assign(this.params, { userName: this.user.userName, projectStartId: value })
            ).then((result) => {
                Toast.clear();
                if (!result.data) {
                    Notify(result.message);
                    return;
                }
                if (result.data.data) {
                    this.mFromdata = result.data.data;
                    if(this.mFromdata.reportFile){
                      Toast.loading({ message: "加载中", forbidClick: false, });
                      fileParsingRequestAnalysisFlowQuery(Object.assign(this.params, { userName: this.user.userName, fileId: this.mFromdata.reportFile[0].id })).then((result) => {
                        Toast.clear();
                        if (!result.data) {
                          Notify(result.message);
                          return;
                        }
                        if (result.data.data) {
                          this.aiDataResult = result.data.data;
                        }
                      });
                    }
                }
            });
        },
        /// 项目起草 获取数据
        /// 获取项目所有的里程碑节点信息 - 获取需要的里程碑节点信息 - 获取发起人信息
        requestDrawupInfo() {
            // this.mFromdata = {};
            console.log("⭕️⭕️⭕️", '起草请求，并且清除之前的模型数据', this.mFromdata);
            Toast.loading({ message: "加载中", forbidClick: false });
            projectMilestoneFindAll(this.params.projectId).then((result) => {
                Toast.clear();
                if (!result.data) {
                    Notify(result.message);
                    return;
                }
                if (result.data.data) {

                    // let detailData = { 'projectName': 'AAAAAAAAAA' };
                    // this.mFromdata.projectName = 'AAAAAAA';
                    // Object.assign(this.mFromdata, detailData);
                    // console.log("⭕️⭕️⭕️", this);

                    // this.$set(this.mFromdata, 'projectName', 'AAAAAAAAAA');
                    // this.$set(this.mFromdata, 'projectName', 'AAAAAAAAAA');
                    // this.mFromdata = Object.assign({}, this.mFromdata, detailData);
                    // console.log("⭕️⭕️⭕️", this.mFromdata);
                    let content = result.data.data.content;
                    if (content && content.length > 0) {
                        /// 通过所有的里程碑节点 获取需要的里程碑节点信息
                        let detailData = content[0];
                        let milestoneMode = detailData.milestoneMode;
                        if (milestoneMode && milestoneMode.length > 0) {
                            this.requestDrawupInfoTwo(milestoneMode);
                        }
                        else {
                            Notify('无里程碑节点信息！');
                        }
                        detailData.customerName = detailData.customerUnitName;
                        detailData.customerCode = detailData.customerId;
                        this.mFromdata = Object.assign({}, this.mFromdata, detailData);
                        console.log("⭕️⭕️", '去展示 项目信息', this.mFromdata);
                    }
                    else {
                        Notify('获取项目信息失败，请重试！');
                    }
                }
            });

            findOnSaleTeamManageByProjectId(this.params.projectId).then((result) => {
                Toast.clear();
                if (!result.data) {
                    Notify(result.message);
                    return;
                }

                if (result.data.data) {

                    let detailData = {};
                    detailData.actualDeliverer = result.data.data.TRUENAME;
                    detailData.actualDelivererAcount = result.data.data.USERNAME;
                    this.mFromdata = Object.assign({}, this.mFromdata, detailData);
                    console.log("⭕️", '发起开工信息', result.data.data);
                }
            });
        },

        requestDrawupInfoTwo(milestoneMode) {
            verifyStartProjectMilestoneNodes(milestoneMode).then((result) => {
                Toast.clear();
                if (!result.data) {
                    Notify(result.message);
                    return;
                }

                if (result.data.data) {

                    let detailData = {};
                    detailData.milestoneNode = result.data.data.milestoneNode;
                    detailData.planEndDate = result.data.data.planEndDate;
                    detailData.milestoneDescribe = result.data.data.milestoneDescription;

                    this.mFromdata = Object.assign({}, this.mFromdata, detailData);
                    console.log("⭕️⭕️", '里程碑节点信息', this.mFromdata);
                }
            });
        },


        /// 年月日 时间格式
        formatter(type, val) {
            if (type === 'year') {
                return `${val}年`;
            }
            else if (type === 'month') {
                return `${val}月`;
            } 
            else if (type === 'day') {
                return `${val}日`;
            }

            return val;
        },

        /// 本地文件选中后的回调
        didFinishPickingFiles(file) {

            let fileData = new FormData();
            fileData.append("pmInsType", this.pmInsType);
            fileData.append("pmInsTypePart", "1");
            fileData.append("files", file.file);

            let params = new Map();
            params.pmInsType = this.pmInsType;
            params.pmInsTypePart = '1';
            params.userName = this.user.userName;
            Toast.loading({ message: "上传中", forbidClick: false });
            uploadFileCommon(fileData, params).then((res) => {
                Toast.clear();
                if (!res.data) {
                    Notify(res.message);
                    return;
                }

                console.log("⭕️", '上传文件', this);
                if (res.data.data) {
                    if (this.mFromdata.reportFile === null || 
                        this.mFromdata.reportFile === undefined) {
                        this.mFromdata.reportFile = [];
                    }

                    this.mFromdata.reportFile=res.data.data.sysFiles;
                    this.$forceUpdate();
                    Dialog.confirm({ title: "提示", message: "是否使用AI大模型能力对文件进行解析？" })
                        .then(() => {
                          let projectIdV = "";
                          if(this.mFromdata.projectID){
                            projectIdV=this.mFromdata.projectID
                          }else if (this.mFromdata.projectEstablishNumber){
                            projectIdV=this.mFromdata.projectEstablishNumber
                          }
                          let businessId = "";
                          if(this.mFromdata.businessId){
                            businessId=this.mFromdata.businessId
                          }
                          Toast.loading({
                            message: '解析中...',
                            forbidClick: false,
                          });
                          fileParsingCurrencyHttp(Object.assign(this.params, { userName: this.user.userName,businessId:businessId ,projectId: projectIdV, fileId: res.data.data.sysFiles[0].id ,analysisCode: "KaiGongJieXi"})).then((result) => {
                            Toast.clear();
                            if (!result.data) {
                              Notify(result.message);
                              return;
                            }
                            if (result.data.data) {
                              this.sysFiles=[]
                              this.sysFiles=res.data.data.sysFiles
                              this.analysisData=[]
                              if (result.data.data) {
                                this.idKey = result.data.data.id;
                                for(var i in result.data.data){
                                  if(i != "id"){
                                    if  (Array.isArray(result.data.data[i])&&result.data.data[i].length<1){
                                      this.analysisData.push({
                                        fieldName: i,
                                        aiOldValue: '[]',//AI解析原数据
                                        aiValue: '[]'//将AI解析的数据进行格式化
                                      });
                                    }else {
                                      this.analysisData.push({
                                        fieldName: i,
                                        aiOldValue: result.data.data[i],//AI解析原数据
                                        aiValue: aiUtils.valueFormatter(result.data.data[i])//将AI解析的数据进行格式化
                                      });
                                    }
                                  }
                                }
                                this.sysFiles[0].state = "执行成功";
                              }else {
                                this.sysFiles[0].state = "执行失败";
                              }
                              for(var i in this.analysisData){
                                this.analysisData[i].dictField = "aiMark"+(parseInt(i)+1);//字段标识
                                this.analysisData[i].dictValue = this.setValueData(this.analysisData[i]);
                                this.analysisData[i].editValue = "";
                              }
                              for(var i in this.analysisData){
                                var dictValue = this.analysisData[i].dictValue;
                                console.log('this.analysisData[i].dictValue'+this.analysisData[i].dictValue)
                                // 时间特殊处理
                                if(this.analysisData[i].dictValue.indexOf("-")>-1 && this.analysisData[i].dictValue.indexOf(":")>-1){
                                  dictValue = this.analysisData[i].dictValue.split(" ")[1];
                                }
                                // 比率
                                if(dictValue.indexOf("%") > -1){
                                  var num_regxa = /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/;//数字
                                  var dictNumStr = dictValue.replace("%","");
                                  if(num_regxa.test(dictNumStr)){
                                    dictValue = dictNumStr;
                                  }
                                }
                                var aiValue = this.analysisData[i].editValue?this.analysisData[i].editValue:(this.analysisData[i].aiValue?this.analysisData[i].aiValue:"");

                                // 判断DICT系统数据和集团数据是否一致
                                if(this.analysisData[i].dictValue=="未提及" || this.analysisData[i].aiValue=="未提及"){
                                  this.analysisData[i].equalResult = "不涉及";
                                }else{
                                  this.analysisData[i].equalResult = dictValue==aiValue?"一致":"不一致";
                                }
                                this.analysisData[i].editValue = this.analysisData[i].editValue || "";
                              }
                            }
                          });
                        })
                        .catch(() => { });
                }
            });
        },
        setValueData(data){
          var valueInfos=''
          console.log("需要对应的名字是"+data.fieldName)
          if(data.fieldName == '项目名称'){
            valueInfos= this.mFromdata.projectName
          }else if(data.fieldName == '计划完工时间'){
            valueInfos= this.mFromdata.planEndDate
          }else if(data.fieldName == '承建单位'){
            valueInfos= this.mFromdata.constructUnit
          }else if(data.fieldName == '施工单位'){
            valueInfos= this.mFromdata.constructionUnit
          }else if(data.fieldName == '会议时间'){
            this.mFromdata.meetingTime=data.aiValue
            valueInfos= data.aiValue
          }else if(data.fieldName == '盖章识别'){
            valueInfos= this.mFromdata.customerName
          }else if(data.fieldName == '监理单位'){
            this.mFromdata.supervisionUnit=data.aiValue
            valueInfos= data.aiValue
          }else if(data.fieldName == '客户单位'){
            valueInfos= this.mFromdata.customerName
          }else if(data.fieldName == '开工时间'){
            valueInfos= this.mFromdata.actualDeliveryTime
          }
          if (!valueInfos){
            valueInfos='未提及'
          }
          return valueInfos
        },
        // 判断是否是base64编码
        isBase64(str){
          var regex = /^(?:[A-Za-z0-9+/]{4})*?(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/;
          return regex.test(str);
        },
        deleteFile(index) {
            Dialog.confirm({ title: "提示", message: "是否删除此附件？" })
                .then(() => {
                    this.mFromdata.reportFile.splice(index, 1);
                })
                .catch(() => { });
        },

        /// 实际开工时间选中 
        actualDeliveryTimeOnComfirm(value) {

            this.showActualDeliveryTimePopupView = false;

            let actualDeliveryTime = moment(value).format('YYYY-MM-DD');
            this.currentDate = actualDeliveryTime;
            this.mFromdata.actualDeliveryTime = actualDeliveryTime;

            // 时间对比、日期对比
            // 对比计划开工时间，大于则 逾期
            let planEndDate = new Date(this.mFromdata.planEndDate);
            if (value - planEndDate > 0) {
                this.mFromdata.postponeStatus = '逾期';
                this.mFromdata.postponeDuration = diffInDays;
            }
            else{
                this.mFromdata.postponeStatus = '未逾期';
            }
            
        },

        onSubmit() {
            if (this.formEditable&&this.analysisData&&this.analysisData.length>0&&this.sysFiles&&this.sysFiles.length>0){
              Toast.loading({ message: '数据保存中...', forbidClick: false });
              saveFileParsingRequestLog(Object.assign(this.params, { userName: this.user.userName,id:this.idKey ,fileId: this.sysFiles[0].id, detailData:this.analysisData })).then((result) => {
                Toast.clear();
                if (!result.data) {
                  Notify(result.message);
                  return;
                }
                if (result.data.errcode===0) {
                  this.controlRule(this.params, this.fromdata.projectID, function () {
                    this.onNext();
                  }.bind(this));
                }
              })
            }
            else {
              this.controlRule(this.params, this.fromdata.projectID, function () {
                this.onNext();
              }.bind(this));
            }
        },

        // 流转下一步
        onNext() {

            if (this.mFromdata.reportFile == null || this.mFromdata.reportFile.length == 0) {
                Toast({ type: 'text', message: '请上传开工报告扫描件', duration: 1000 });
                return;
            }

            //提交流转
            console.log("传给递交页面:", this.params)
            console.log("formDataformData", JSON.stringify(this.mFromdata));
            var formSendData = { "htmlParamMap": {} };
            formSendData.htmlParamMap = this.mFromdata;
            formSendData.id = this.nFromdata.id;
            formSendData.pmInsId = this.nFromdata.pmInsId;
            formSendData.processType = this.params.pmInsType
            formSendData.workItemId = this.params.workItemId;

            let currentUserCode = util.encrypt(this.user.userName);
            var params1 = {
                kv: {
                    currentUserCode: currentUserCode,
                    source: 'MOBILE',
                    location: this.params.location,
                    processInstId: this.params.processInstId,
                    processDefName: this.params.processDefName,
                    processType: this.params.pmInsType,
                },
            };

            var params2 = {
                kv: {
                    "currentUserCode": currentUserCode,
                    "source": 'MOBILE',
                    "location": this.params.location,
                    "processInstId": this.params.processInstId,
                    'processType': this.params.pmInsType,
                    'receiptCode': this.params.processInstId
                },
            };

            var params3 = {
                kv: {
                    "source": 'MOBILE',
                    "currentUserCode": currentUserCode,
                    "workItemId": this.params.todoType == 3 ? "" : this.params.workItemId,
                    "processInstId": this.params.processInstId,
                    "location": this.params.location,
                    "notificationId": this.params.todoType == 3 ? this.params.wfnid : ""
                },
            };

            console.log('AAAAAAA', this.user.userName, params1);
            localStorage.setItem('submitPageParam', JSON.stringify({
                getDecisionsUrl: 'decisionAndUser$api$getDecisions',
                getUserUrl: 'decisionAndUser$api$getOrgAndUser',
                tosubmintUrl: 'applicationFormProject$api$startSubmitProcess',
                getDecisionsParams: params1,
                getUserParams: params2,
                tosubmintParams: params3,

                formData: formSendData,
                fromMoa: this.params.fromMoa,
                type: this.params.todoType == 3 ? "toRead" : "toDo"
            }));
            this.$router.push({
                name: "srqrsubmit"
            });
        },

        

    },
};
</script>

<style scoped>
/* @import url();*/
</style>